/**
 * 
 */
package com.jootu.cc.ccapi.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;

import com.jootu.cc.ccapi.domain.resultmap.JsonResult;
import com.jootu.cc.ccapi.domain.resultmap.ResultCode;

/**
 *
 * @author:antch
 * @date:2017年8月10日
 * @Description:（Controller异常处理）
 *
 */

@RestControllerAdvice
public class ControllerExceptionHandler {

	@ExceptionHandler(value = NoHandlerFoundException.class)
	public ResponseEntity<JsonResult> defaultExceptionHandler(HttpServletRequest request, Exception e) {
		long startTime = System.currentTimeMillis();
		
		JsonResult j = new JsonResult();
		j.setCode(ResultCode.NOT_FOUND);
		j.setMess(ResultCode.NOT_FOUND_MEG);
		j.setProcessTime(startTime - System.currentTimeMillis());
		
		return ResponseEntity.ok(j);
	}
}
